package com.dingwen.treasure.business.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.dingwen.treasure.base.constant.RabbitmqConstant;
import com.dingwen.treasure.business.service.OweFeeService;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 　OweFeeServiceImpl
 * 　@author dingwen
 * 　@date 2022/6/5
 */
@Service
public class OweFeeServiceImpl implements OweFeeService {

    /**
     * mq
     */
    @Resource
    private  RabbitTemplate rabbitTemplate;

    /**
     * 欠费
     */
    @Override
    public void oweFee() {
        CorrelationData correlationData = new CorrelationData();
        correlationData.setId("6666");
        // 交换机通过路由键投递到指定路由
        rabbitTemplate.convertAndSend(RabbitmqConstant.DIRECT_EXCHANGE_SMS,
                RabbitmqConstant.ROUTER_KEY_SMS, RandomUtil.randomNumbers(10), correlationData);
    }
}
